//
//  IManager+ModuleMerchantDetailOtherShop.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-9-11.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+ModuleMerchantDetailOtherShop.h"
#import "FrameworkRelativeDefines.h"
#import "NSString+NSString_Ex_.h"
#import "RequestUtlity.h"
#import "NetUrlDefines.h"
#import "RCMerchantsListDataModel.h"
#import "GloableEngineService.h"

@implementation IManager(ModuleMerchantDetailOtherShop)

-(int64_t)requestMerchantDetailOtherShop:(NSString *)shopID withLat:(NSString *)lat withLon:(NSString *)lon withDelegate:(id<IManagerDelegate>)delegate{
    if ([NSString stringIsNullOrEmpty:shopID]) {
        return kInvalidRequestId;
    }
    double newLat = 0.0;
    double newLon = 0.0;
    if (![NSString stringIsNullOrEmpty:lat] && ![NSString stringIsNullOrEmpty:lon]) {
        newLat = [lat doubleValue];
        newLon = [lon doubleValue];
    }
    if (newLat == 0.0 || newLon == 0.0) {
        CLLocation *coor = [[GloableEngineService sharedInstance] locationInfo];
        newLat = coor.coordinate.latitude;
        newLon = coor.coordinate.longitude;
    }
    
    NSString *urlSuffix = [NSString stringWithFormat:kRCMerchantDetailOtherShopPrefix,shopID,newLat,newLon];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCMerchantsListDataModel class]
                                                     withDataDelegate:delegate];
}

@end
